#include "WebInterface.h"



char * WebInterface_WorkConfig_html(char *html, S_ConfClock * pConf){
static const char html_head[] PROGMEM = R"==(
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>联网时钟配置界面</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
background-color: #fff;
padding: 30px;
border-radius: 10px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
width: 80%;
height: 95%;
max-width: 800px;
position: relative;
}
.form-title {
text-align: center;
margin-bottom: 20px;
border-bottom: 2px solid #ccc;
padding-bottom: 10px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
.form-group select,
.line-group input[type='number'] {
width: 100%;
padding: 10px;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 5px;
}
.form-group textarea {
height: 100px;
}
.error-message {
color: red;
font-size: 0.8em;
margin-top: 5px;
}
.checkbox-group,
.line-group {
margin-bottom: 20px;
}
.checkbox-group label,
.line-group label {
display: inline-block;
margin-right: 20px;
}
.checkbox-group input[type='checkbox'],
.line-group input[type='radio'] {
margin-right: 5px;
}
.line-group input[type='number'] {
  width: 40px;
}
.submit-btn {
display: block;
width: 100%;
padding: 15px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1.1em;
transition: background-color 0.3s;
}
.submit-btn:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class='container'>
<h2 class='form-title'>联网时钟配置界面</h2>
<form action='/workconfig' method='post'>
<div class='form-group'>
<label for='talktime'>整点报时:</label>
<select id='talktime' name='talktime'>
  )==";

int offset = sprintf(html, "%s", html_head);
  offset += sprintf(html+offset, "<option value='0' %s>关闭</option>", pConf->chimehour==e_ChimeHour_Off?"selected":"");
  offset += sprintf(html+offset, "<option value='1' %s>每半小时</option>", pConf->chimehour==e_ChimeHour_HalfHour?"selected":"");
  offset += sprintf(html+offset, "<option value='2' %s>每一小时</option>", pConf->chimehour==e_ChimeHour_AnHour?"selected":"");
  offset += sprintf(html+offset, "<option value='3' %s>每十二小时</option></select></div><div class='checkbox-group'>", pConf->chimehour==e_ChimeHour_12Hour?"selected":"");
  offset += sprintf(html+offset, "<label for='brightnessControl'>亮度:<input type='range' name='brightnessControl' id='brightnessControl' min='0' max='7' step='1' value='%d'></label>", pConf->brightness>7?7:pConf->brightness);
  offset += sprintf(html+offset, "<label for='auto_brightness'><input type='checkbox' id='auto_brightness' name='auto_brightness' %s> 自动</label>", pConf->auto_brightness?"checked":"");

  offset += sprintf(html+offset, "</div><div class='line-group'><label >副屏:</label>");
  offset += sprintf(html+offset, "<label><input type='radio' id='gender_temp' name='gender' value='1' %s> 温度</label>", pConf->screen==e_SecondScreen_Temp?"checked":"");
  offset += sprintf(html+offset, "<label><input type='radio' id='gender_second' name='gender' value='2' %s> 秒</label>", pConf->screen==e_SecondScreen_Second?"checked":"");
  offset += sprintf(html+offset, "<label><input type='radio' id='gender_off' name='gender' value='0' %s> 关闭</label>", pConf->screen==e_SecondScreen_off?"checked":"");

  offset += sprintf(html+offset, "</div><div class='line-group'><label >线位:</label>");
  offset += sprintf(html+offset, "<label><input type='radio' id='usb_position_left' name='usb_position' value='0' %s> 左 </label>", pConf->usb_position==e_usb_position_left?"checked":"");
  offset += sprintf(html+offset, "<label><input type='radio' id='usb_position_right' name='usb_position' value='1' %s> 右</label>", pConf->usb_position==e_usb_position_right?"checked":"");

  offset += sprintf(html+offset, "</div><div class='line-group'><label >日期:</label>");
  offset += sprintf(html+offset, "<label>每隔<input type='number' id='date_interval' name='date_interval' value='%d' min='0' max='255' > 秒显示一次日期</label>", pConf->date_interval);

  offset += sprintf(html+offset, "</div><div class='line-group'><label >时制:</label>");
  offset += sprintf(html+offset, "<label><input type='radio' id='clock_type_12' name='clock_type' value='1' %s> 12小时</label>", pConf->clock_type==e_ClockType_12?"checked":"");
  offset += sprintf(html+offset, "<label><input type='radio' id='clock_type_24' name='clock_type' value='2' %s> 24小时</label>", pConf->clock_type==e_ClockType_24?"checked":"");

  sprintf(html+offset, "</div><button type='submit' class='submit-btn'>提交配置</button></form></div></body></html>");

  return html;
}